package com.uam.core.business;

import com.uam.core.entity.model.TaskModel;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

/**
 * 任务监控入口
 *
 * @author uam
 */
@Slf4j
public class RouteInItThread implements Runnable {

    private RouteStatusInfo routeStatusInfo;

    private long interval;

    public  RouteInItThread(RouteStatusInfo routeStatusInfo,long interval){
        this.routeStatusInfo=routeStatusInfo;
        this. interval=interval;
    }

    @SneakyThrows
    @Override
    public void run() {
           while (true){
               try {
                   List<TaskModel> taskModels = routeStatusInfo.taskRouteInfo();
                   if (taskModels == null || taskModels.size() == 0) {
                       Thread.sleep(interval);
                   }
               }catch (Exception e){
                   log.error("监控任务错误",e);
               }
           }
    }
}
